#!/bin/bash
mongodbUri="mongodb://localhost:27017/nfu_town"

echo "Please set the username and password for the MongoDB database"
read -p "Enter username: " username
read -sp "Enter password: " password
echo

# Command to create the user
mongosh "$mongodbUri" --eval "db.createUser({
    user: '$username',
    pwd: '$password',
    roles: [{ role: 'readWrite', db: 'nfu_town' }]
})"

echo "🎉 User $username has been successfully created and granted readWrite permissions for the nfu_town database"
